package com.woniuxy.microfixeddepositserver.dao;

import com.woniuxy.bean.bank.BankBean;
import com.woniuxy.microfixeddepositserver.bean.detail.OwnRegularBean;
import com.woniuxy.microfixeddepositserver.bean.detail.SecurityBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author: masterhai
 * @date: 2021/4/15:21:07
 * @description:
 */

public interface RegularDao {
    //查询机构信息
    @Select("select title,src from organization where status = 1")
    List<SecurityBean> getOrganization ();

    //查询银行列表
    @Select("select bankimgSrc,bankName,singleLimit,dayLimit from bankList where status = 1 ")
    List<BankBean> getBankList ();

    //储存定期理财每日平台提成收益
    @Insert("insert into platform_earnings(product_type,create_time,modify_time,trustee_fee) values(#{type},NOW(),NOW(),#{earn})")
    Integer saveTrusteeFee (@Param("type") String type, @Param("earn") Double earn);

    //储存定期产品赎回时平台获取的交易手续费收益
    @Insert("insert into platform_earnings(product_type,create_time,modify_time,redemption_fee_income) values(#{type},NOW(),NOW(),#{earn})")
    Integer saveRedemptionFeeIncome (@Param("type") String type, @Param("earn") Double earn);

    //查询用户购买的定期产品
    @Select(" select id pid ,member_account memberAccount,fixed_deposit_id productId,order_number orderNumber,confirmCapital," +
            "unConfirmCapital,over_all_balance overAllBalance," +
            "today_earnings todayEarnings,total_earnings totalEarnings,yield_rates yieldYates ,product_name productName," +
            "calculate_earnings_day doDay from member_fixed_account " +
            "where member_account=#{username} and status=1")
    List<OwnRegularBean> getBuyRegular (@Param("username") String username);

    @Select("select sum(total_earnings) totalEarnings from member_fixed_account")
    List<OwnRegularBean> getAllEarnings ();

//    @Select("select buyDay from member_fixed_account where id=#{pid} and status=1")
//    Integer getBuyDay (@Param("pid") Integer pid);

    @Select("select period from fixed_time_deposit where id=#{fid} and status=1")
    Integer getPeriod (@Param("fid") Integer fid);
}
